home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 June / june_2000.iso / Site Building / JavaNavigator / JavaNavigator.exe / %MAINDIR% / JavaNavigatorV50.exe / JAVATabR.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-01-30  |  11.2 KB  |  522 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.Label;
  11. import java.awt.LayoutManager;
  12. import java.awt.MediaTracker;
  13. import java.awt.Panel;
  14. import java.net.MalformedURLException;
  15. import java.net.URL;
  16. import java.util.NoSuchElementException;
  17. import java.util.StringTokenizer;
  18.  
  19. public class JAVATabR extends Applet implements Runnable {
  20.    String sDefMO = "1st JAVA Navigator[Tab], (c)1997-2000 AUSCOMP-WorldWide (www.auscomp.com)";
  21.    String sCopyright = "AUSCOMP (www.auscomp.com)";
  22.    int xSwitch = 4;
  23.    String sLoading = "1st JAVA Navigator V5.5";
  24.    Thread thJAVATab;
  25.    String[] aHref;
  26.    String[] aFrame;
  27.    String[] aHref2;
  28.    String[] aFrame2;
  29.    String[] aMsg;
  30.    String[] tempString;
  31.    String sText = "";
  32.    String sHref = "";
  33.    String sFrame = "";
  34.    String sHref2 = "";
  35.    String sFrame2 = "";
  36.    String sMsg = "";
  37.    String sMsgOld = "";
  38.    int iLoading;
  39.    int iTabCnt;
  40.    int oldx;
  41.    int iTabDefault = 999;
  42.    int iBGRed = 255;
  43.    int iFGRed;
  44.    int iBHRed;
  45.    int iFHRed = 255;
  46.    int iBGGreen = 255;
  47.    int iFGGreen;
  48.    int iBHGreen;
  49.    int iFHGreen = 255;
  50.    int iBGBlue = 255;
  51.    int iFGBlue;
  52.    int iBHBlue;
  53.    int iFHBlue;
  54.    Font fFont = new Font("Dialog", 0, 12);
  55.    private boolean bCopyright = false;
  56.    private boolean allLoaded = false;
  57.    Image imgBG;
  58.    // $FF: renamed from: g1 java.awt.Graphics
  59.    Graphics field_0;
  60.    boolean fAuscomp = true;
  61.    String sMOUSEOVERSOUND = "none";
  62.    String sMOUSECLICKSOUND = "none";
  63.    int oldTabPanel = -1;
  64.    TabPanel tabPanel1;
  65.    Label label1;
  66.  
  67.    void tabPanel1_MouseMove(Event event) {
  68.       int x = 0;
  69.  
  70.       try {
  71.          x = this.tabPanel1.setTabLabelColor(event);
  72.  
  73.          try {
  74.             if (this.oldTabPanel != x && !this.sMOUSEOVERSOUND.equals("none")) {
  75.                ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSEOVERSOUND);
  76.             }
  77.  
  78.             this.oldTabPanel = x;
  79.          } catch (Exception var3) {
  80.          }
  81.  
  82.          if (x == 999 && this.oldx != 999) {
  83.             this.tabPanel1.setMOLabelColor(this.tabPanel1.getMOColor(), x);
  84.             this.sMsg = this.sDefMO;
  85.          } else {
  86.             this.sMsg = this.aMsg[x];
  87.          }
  88.  
  89.          this.oldx = x;
  90.          this.sMsg = this.sMsg.trim();
  91.          if (this.sMsg != this.sMsgOld) {
  92.             if (this.sMsg.toLowerCase().equals("none")) {
  93.                ((Applet)this).showStatus(" ");
  94.             } else {
  95.                ((Applet)this).showStatus(this.sMsg);
  96.             }
  97.  
  98.             this.sMsgOld = this.sMsg;
  99.             return;
  100.          }
  101.       } catch (ArrayIndexOutOfBoundsException var4) {
  102.       }
  103.  
  104.    }
  105.  
  106.    void tabPanel1_MouseUp(Event event) {
  107.       try {
  108.          if (!this.sMOUSECLICKSOUND.equals("none")) {
  109.             ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSECLICKSOUND);
  110.          }
  111.       } catch (Exception var6) {
  112.       }
  113.  
  114.       try {
  115.          int iTabIx = this.tabPanel1.getCurrentPanelNdx();
  116.          this.sHref = this.aHref[iTabIx];
  117.          this.sFrame = this.aFrame[iTabIx];
  118.          this.sHref2 = this.aHref2[iTabIx];
  119.          this.sFrame2 = this.aFrame2[iTabIx];
  120.          this.sHref = this.sHref.trim();
  121.          this.sFrame = this.sFrame.trim();
  122.          this.sHref2 = this.sHref2.trim();
  123.          this.sFrame2 = this.sFrame2.trim();
  124.          if (!this.sHref.toLowerCase().equals("none")) {
  125.             try {
  126.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref), this.sFrame);
  127.             } catch (MalformedURLException var4) {
  128.             }
  129.          }
  130.  
  131.          if (!this.sHref2.toLowerCase().equals("none")) {
  132.             try {
  133.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref2), this.sFrame2);
  134.                return;
  135.             } catch (MalformedURLException var3) {
  136.                return;
  137.             }
  138.          }
  139.       } catch (Exception var5) {
  140.       }
  141.  
  142.    }
  143.  
  144.    public void start() {
  145.       this.field_0 = ((Component)this).getGraphics();
  146.       this.paint(this.field_0);
  147.       this.thJAVATab = new Thread(this);
  148.       this.thJAVATab.start();
  149.    }
  150.  
  151.    public void stop() {
  152.       this.thJAVATab.stop();
  153.       this.thJAVATab = null;
  154.    }
  155.  
  156.    public void paint(Graphics g) {
  157.       ++this.iLoading;
  158.       g.drawString(this.sLoading, 10, 15);
  159.       g.drawString("Loading resource No." + this.iLoading + " - Please wait", 10, 35);
  160.    }
  161.  
  162.    public void run() {
  163.       if (!this.allLoaded) {
  164.          this.constructTab();
  165.          this.tabPanel1.show(true);
  166.          if (this.iTabDefault < 999) {
  167.             this.tabPanel1.setCurrentPanelNdx(this.iTabDefault);
  168.             this.tabPanel1_MouseUp((Event)null);
  169.             return;
  170.          }
  171.  
  172.          this.tabPanel1.setCurrentPanelNdx(0);
  173.       }
  174.  
  175.    }
  176.  
  177.    public void init() {
  178.       super.init();
  179.       ((Container)this).setLayout((LayoutManager)null);
  180.       ((Panel)this).addNotify();
  181.       this.tabPanel1 = new TabPanel();
  182.       this.tabPanel1.setLayout((LayoutManager)null);
  183.       switch (this.xSwitch) {
  184.          case 0:
  185.             this.sLoading = "1st JAVA Tab - Evaluation Copy";
  186.             return;
  187.          case 1:
  188.             this.sLoading = "1st JAVA Tab - Registered";
  189.             return;
  190.          case 2:
  191.             this.sLoading = "1st JAVA Tab";
  192.             return;
  193.          case 3:
  194.             this.sLoading = "1st JAVA Navigator[Tab] - Evaluation Copy";
  195.             return;
  196.          case 4:
  197.             this.sLoading = "1st JAVA Navigator[Tab] - Registered";
  198.          default:
  199.       }
  200.    }
  201.  
  202.    private void constructTab() {
  203.       String strBG = "";
  204.  
  205.       try {
  206.          strBG = ((Applet)this).getParameter("COPYRIGHT");
  207.          if (strBG.indexOf(this.sCopyright) > 0) {
  208.             this.bCopyright = true;
  209.          } else {
  210.             this.bCopyright = false;
  211.          }
  212.       } catch (Exception var20) {
  213.       }
  214.  
  215.       try {
  216.          this.sMOUSEOVERSOUND = "none";
  217.          strBG = ((Applet)this).getParameter("MOUSEOVERSOUND");
  218.          if (strBG != null) {
  219.             this.sMOUSEOVERSOUND = strBG;
  220.          }
  221.       } catch (Exception var19) {
  222.       }
  223.  
  224.       try {
  225.          this.sMOUSECLICKSOUND = "none";
  226.          strBG = ((Applet)this).getParameter("MOUSECLICKSOUND");
  227.          if (strBG != null) {
  228.             this.sMOUSECLICKSOUND = strBG;
  229.          }
  230.       } catch (Exception var18) {
  231.       }
  232.  
  233.       try {
  234.          strBG = ((Applet)this).getParameter("TAB_BG");
  235.          if (strBG == null) {
  236.             this.iBGRed = 192;
  237.             this.iBGGreen = 192;
  238.             this.iBGBlue = 192;
  239.          } else {
  240.             this.iBGRed = this.getCOLOR(0, "TAB_BG", strBG);
  241.             this.iBGGreen = this.getCOLOR(1, "TAB_BG", strBG);
  242.             this.iBGBlue = this.getCOLOR(2, "TAB_BG", strBG);
  243.          }
  244.       } catch (Exception var17) {
  245.       }
  246.  
  247.       Dimension s = ((Component)this).size();
  248.       this.tabPanel1.reshape(0, 0, s.width, s.height);
  249.       this.tabPanel1.setBackground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  250.  
  251.       try {
  252.          strBG = ((Applet)this).getParameter("TAB_FG");
  253.          if (strBG == null) {
  254.             this.iBGRed = 0;
  255.             this.iBGGreen = 0;
  256.             this.iBGBlue = 0;
  257.          } else {
  258.             this.iBGRed = this.getCOLOR(0, "TAB_FG", strBG);
  259.             this.iBGGreen = this.getCOLOR(1, "TAB_FG", strBG);
  260.             this.iBGBlue = this.getCOLOR(2, "TAB_FG", strBG);
  261.          }
  262.       } catch (Exception var16) {
  263.       }
  264.  
  265.       this.tabPanel1.setLabelColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  266.       ((Component)this).setForeground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  267.  
  268.       try {
  269.          strBG = ((Applet)this).getParameter("TAB_DEFAULT");
  270.          if (strBG == null) {
  271.             this.iTabDefault = 999;
  272.          } else {
  273.             this.iTabDefault = Integer.parseInt(strBG);
  274.          }
  275.       } catch (Exception var15) {
  276.       }
  277.  
  278.       try {
  279.          strBG = ((Applet)this).getParameter("TABONBOTTOM");
  280.          if (strBG == null) {
  281.             this.tabPanel1.setTabsOnBottom(false);
  282.          } else {
  283.             this.tabPanel1.setTabsOnBottom(true);
  284.             if (strBG.toLowerCase().equals("no")) {
  285.                this.tabPanel1.setTabsOnBottom(false);
  286.             }
  287.          }
  288.       } catch (Exception var14) {
  289.       }
  290.  
  291.       try {
  292.          strBG = ((Applet)this).getParameter("TAB_FONT");
  293.          String fName = "";
  294.          String fStyle = "";
  295.          String fSize = "";
  296.          int iStyle = 0;
  297.          if (strBG != null) {
  298.             StringTokenizer parser = new StringTokenizer(strBG, ";");
  299.  
  300.             try {
  301.                fName = parser.nextToken();
  302.                fStyle = parser.nextToken();
  303.                fSize = parser.nextToken();
  304.                if (fStyle.trim().toLowerCase().equals("bold")) {
  305.                   iStyle = 1;
  306.                }
  307.  
  308.                if (fStyle.trim().toLowerCase().equals("italic")) {
  309.                   iStyle = 2;
  310.                }
  311.  
  312.                this.fFont = new Font(fName, iStyle, Integer.parseInt(fSize.trim()));
  313.             } catch (NoSuchElementException var11) {
  314.                System.out.println(strBG + " Parameter Error(1)");
  315.             } catch (Exception var12) {
  316.                System.out.println(strBG + " Parameter Error(2)");
  317.             }
  318.          }
  319.  
  320.          this.tabPanel1.setFont(this.fFont);
  321.       } catch (Exception var13) {
  322.       }
  323.  
  324.       try {
  325.          strBG = ((Applet)this).getParameter("TAB_MOUSEOVER");
  326.          if (strBG == null) {
  327.             this.iBGRed = 255;
  328.             this.iBGGreen = 0;
  329.             this.iBGBlue = 0;
  330.          } else {
  331.             this.iBGRed = this.getCOLOR(0, "TAB_MOUSEOVER", strBG);
  332.             this.iBGGreen = this.getCOLOR(1, "TAB_MOUSEOVER", strBG);
  333.             this.iBGBlue = this.getCOLOR(2, "TAB_MOUSEOVER", strBG);
  334.          }
  335.  
  336.          this.tabPanel1.setMOColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  337.       } catch (Exception var10) {
  338.       }
  339.  
  340.       try {
  341.          this.imgBG = null;
  342.          strBG = ((Applet)this).getParameter("TAB_BG_IMAGE");
  343.          if (strBG != null) {
  344.             this.imgBG = ((Applet)this).getImage(((Applet)this).getCodeBase(), strBG);
  345.             MediaTracker m = new MediaTracker(this);
  346.  
  347.             try {
  348.                m.addImage(this.imgBG, 0);
  349.                m.waitForAll();
  350.             } catch (InterruptedException var8) {
  351.                return;
  352.             }
  353.  
  354.             if (this.imgBG.getHeight(this) > 0) {
  355.                this.tabPanel1.setBGImage(this.imgBG);
  356.             }
  357.          }
  358.       } catch (Exception var9) {
  359.       }
  360.  
  361.       ((Container)this).add(this.tabPanel1);
  362.       this.tabPanel1.show(false);
  363.  
  364.       int i;
  365.       for(i = 0; ((Applet)this).getParameter("TAB" + i) != null; ++i) {
  366.       }
  367.  
  368.       this.iTabCnt = i + 1;
  369.       this.tempString = new String[this.iTabCnt];
  370.       this.aHref = new String[this.iTabCnt];
  371.       this.aFrame = new String[this.iTabCnt];
  372.       this.aHref2 = new String[this.iTabCnt];
  373.       this.aFrame2 = new String[this.iTabCnt];
  374.       this.aMsg = new String[this.iTabCnt];
  375.  
  376.       for(int var34 = 0; ((Applet)this).getParameter("TAB" + var34) != null; ++var34) {
  377.          this.workParam(((Applet)this).getParameter("TAB" + var34), var34);
  378.          this.tabPanel1.add(this.label1);
  379.          if (var34 == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  380.             this.tabPanel1.add(this.label1);
  381.          }
  382.       }
  383.  
  384.       if (!this.bCopyright) {
  385.          this.tempString[0] = "Copyright parameter missing";
  386.          this.aMsg[0] = "Copyright applet parameter missing in the HTML code.";
  387.       }
  388.  
  389.       this.tabPanel1.setPanelLabels(this.tempString);
  390.       this.tabPanel1.show();
  391.       this.allLoaded = true;
  392.    }
  393.  
  394.    public boolean handleEvent(Event event) {
  395.       if (event.target == this.tabPanel1 && event.id == 502) {
  396.          this.tabPanel1_MouseUp(event);
  397.          return true;
  398.       } else if (event.target == this.tabPanel1 && event.id == 503) {
  399.          this.tabPanel1_MouseMove(event);
  400.          return true;
  401.       } else {
  402.          return super.handleEvent(event);
  403.       }
  404.    }
  405.  
  406.    private int getCOLOR(int iColor, String sWhat, String sPBG) {
  407.       int iRed = 255;
  408.       int iBlue = 255;
  409.       int iGreen = 255;
  410.       StringTokenizer parser = new StringTokenizer(sPBG, ",");
  411.  
  412.       try {
  413.          String sRed = parser.nextToken();
  414.          String sGreen = parser.nextToken();
  415.          String sBlue = parser.nextToken();
  416.          iRed = Integer.parseInt(sRed);
  417.          iGreen = Integer.parseInt(sGreen);
  418.          iBlue = Integer.parseInt(sBlue);
  419.       } catch (NoSuchElementException var11) {
  420.          System.out.println(sWhat + " Parameter Error(1)");
  421.       } catch (Exception var12) {
  422.          System.out.println(sWhat + " Parameter Error(2)");
  423.       }
  424.  
  425.       switch (iColor) {
  426.          case 0:
  427.             return iRed;
  428.          case 1:
  429.             return iGreen;
  430.          case 2:
  431.             return iBlue;
  432.          default:
  433.             return 255;
  434.       }
  435.    }
  436.  
  437.    private void workParam(String sItem, int iTCnt) {
  438.       this.sHref = "None";
  439.       this.sFrame = "None";
  440.       this.sHref2 = "None";
  441.       this.sFrame2 = "None";
  442.       this.sMsg = "None";
  443.       if (sItem.substring(0, 3).equals("***")) {
  444.          this.sHref = "None";
  445.          this.sFrame = "None";
  446.          this.sHref2 = "None";
  447.          this.sFrame2 = "None";
  448.          this.sMsg = "None";
  449.       } else {
  450.          StringTokenizer parser = new StringTokenizer(sItem, ";");
  451.          int iCnt = parser.countTokens() - 4;
  452.          if (iCnt != 0 && iCnt != 2) {
  453.             System.out.println("*** Warning in parameter '" + sItem + "' - Item count is ( " + parser.countTokens() + " ) instead of ( 6 ) *** ");
  454.          }
  455.  
  456.          try {
  457.             this.sText = parser.nextToken();
  458.             this.sHref = parser.nextToken();
  459.             this.sFrame = parser.nextToken();
  460.             this.sMsg = parser.nextToken();
  461.             this.sHref2 = parser.nextToken();
  462.             this.sFrame2 = parser.nextToken();
  463.          } catch (NoSuchElementException var6) {
  464.          } catch (Exception var7) {
  465.             System.out.println(sItem + " Parameter Error(3)");
  466.          }
  467.  
  468.          if (iTCnt == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  469.             this.tempString[iTCnt] = "Evaluation Copy";
  470.             this.aHref[iTCnt] = "http://www.auscomp.com";
  471.             this.aFrame[iTCnt] = "_blank";
  472.             this.aHref2[iTCnt] = "None";
  473.             this.aFrame2[iTCnt] = "None";
  474.             this.aMsg[iTCnt] = this.sDefMO;
  475.          }
  476.  
  477.          if (iTCnt == 0 && this.xSwitch == 2) {
  478.             try {
  479.                this.fAuscomp = false;
  480.                if (((Applet)this).getCodeBase().equals(new URL("http://10.0.0.2/JTab/"))) {
  481.                   this.fAuscomp = true;
  482.                } else {
  483.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com/JTab/"))) {
  484.                      this.fAuscomp = true;
  485.                   }
  486.  
  487.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com.au/JTab/"))) {
  488.                      this.fAuscomp = true;
  489.                   }
  490.                }
  491.             } catch (MalformedURLException var5) {
  492.             }
  493.  
  494.             if (!this.fAuscomp) {
  495.                this.tempString[iTCnt] = "Illegal copy of 1st JAVA Tab";
  496.                this.aHref[iTCnt] = "http://www.auscomp.com";
  497.                this.aFrame[iTCnt] = "_blank";
  498.                this.aHref2[iTCnt] = "None";
  499.                this.aFrame2[iTCnt] = "None";
  500.                this.aMsg[iTCnt] = "Non registered copy of 1st JAVA Navigator (c)1997-2000 Auscomp-WorldWide (www.auscomp.com)";
  501.                this.tabPanel1.add(this.label1);
  502.             }
  503.          }
  504.  
  505.          if (this.xSwitch == 0 || this.xSwitch == 3) {
  506.             ++iTCnt;
  507.          }
  508.  
  509.          if (this.xSwitch == 2 && !this.fAuscomp) {
  510.             ++iTCnt;
  511.          }
  512.  
  513.          this.tempString[iTCnt] = this.sText;
  514.          this.aHref[iTCnt] = this.sHref;
  515.          this.aFrame[iTCnt] = this.sFrame;
  516.          this.aHref2[iTCnt] = this.sHref2;
  517.          this.aFrame2[iTCnt] = this.sFrame2;
  518.          this.aMsg[iTCnt] = this.sMsg;
  519.       }
  520.    }
  521. }
  522.